<?php
// +----------------------------------------------------------------------
// | snake
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 http://baiyf.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: NickBai <1902822973@qq.com>
// +----------------------------------------------------------------------
namespace app\common\validate;

use think\Validate;

class ApplyValidate extends Validate
{

    protected $rule = [
        ['baby_name|宝宝姓名', 'require|length:1,20'],
        ['mobile|手机号', 'require|checkMobile'],
        ['age|宝宝年龄', 'require|number'],
        ['address|所在地区', 'require'],
        ['picture|宝宝图片', 'require']
    ];

    protected $scene = [
        'add'=>['baby_name','mobile','age','address', 'picture'],
        'edit'=>['baby_name','mobile','age','address', 'picture'],
    ];

    protected $message = [
        'mobile.checkMobile'=>'手机号格式不正确',
    ];

    public function checkMobile($value){
        return (boolean)preg_match('/^1[23465789]{1}\d{9}$/', $value);
    }



}
